#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define pb emplace_back
#define ld long double
#define cmax(a,b) ((a)=max((a),(b)))
#define cmin(a,b) ((a)=min((a),(b)))
using namespace std;
namespace IO{
	const int maxn=(1<<20);char *p1,*p2,buf[maxn];
	#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,maxn,stdin),p1==p2)?EOF:*p1++)
	int read(){
		int f=1,k=0;char c;
		while(!isdigit(c=gc()))if(c=='-')f=-1;
		while(isdigit(c))k=k*10+c-48,c=gc();
		return f*k;
	}
	void write(int k,char c){
		if(k<0){putchar('-');k=-k;}
		char st[21];int top=0;
		do{st[++top]=(k%10)|48,k/=10;}while(k);
		while(top)putchar(st[top--]);
		putchar(c);
	}
}using namespace IO;
const int N=1e4+10,mod=1e9+7;
int n,k,x,y,dep[N],st[N],mxdep[N],top,cnt,tmp[N],dis[N][N],tot,ans,root;bool flag;
vector<int> E[N],G[N];
bool vis[N],can[N];
void dfs(int u,int fa){
	dep[u]=dep[fa]+1;
	st[++top]=u;
	dis[root][u]=dep[u]-1;
	cmax(mxdep[root],dep[u]);
	if(dep[u]==k&&!flag){
		flag=1;
		for(int i=1;i<=top;++i)
			tmp[++tot]=st[i];
	}
	bool son_can=0;
	if(dep[u]==k+1) G[root].pb(u);
	for(int v:E[u])
		if(v^fa){
			dfs(v,u);
			son_can=1;
		}
	if(dep[u]>=k&&!son_can){
		for(int i=1;i<=top;++i)
			can[st[i]]=1;
	}
	--top;
}
void check(int u){
	if(vis[u])return;
	vis[u]=1;
	for(int i=1;i<=top;++i)
		flag&=(dis[u][st[i]]>=k);
	st[++top]=u;
	for(auto v:G[u]){
		if(!flag)break;
		check(v);
	}
}
void pd(int u,int d,int fa){
	if(d>=k)flag=0;
	for(int v:E[u])
		if(!vis[v]&&v!=fa&&flag)
			pd(v,d+1,u);
}
int qp(int x,int k){
	int res=1;
	while(k){
		if(k&1)res=1ll*res*x%mod;
		x=1ll*x*x%mod;k>>=1;
	}
	return res;
}
signed main(){
	freopen("life.in","r",stdin);
	freopen("life.out","w",stdout);
	n=read(),k=read();
	if(n>200){
		puts("YES");
		return write(k,'\n'),0;
	}
	for(int i=2;i<=n;++i){
		x=read(),y=read();
		E[x].pb(y);
		E[y].pb(x); 
	}
	for(int i=1;i<=n;++i){
		root=i;top=0;
		dfs(root,0);
//		if(mxdep[i]<k){
//			cerr<<"FUCK "<<i<<'\n';
//		}
	}
	for(int i=1;i<=n;++i)if(!can[i])++cnt;
	if(!flag){
		puts("YES");
		return write(qp(2,n),'\n'),0;
	}
	for(int i=1;i<=tot;++i){
		flag=1;top=0;
		memset(vis,0,sizeof vis);
		check(tmp[i]);
		for(int i=1;i<=n;++i)if(!vis[i])pd(i,1,0);
		ans+=flag;
	}
	puts(ans?"YES":"NO");
	write(1ll*ans*qp(2,cnt)%mod,'\n');
	return 0;
}
/*
4 2
2 1
3 2
2 4
*/



